const express = require('express');
const app = express();
const _ = require('underscore');
const bodyParser = require('body-parser');
const jsonParser = bodyParser.json();
const setting = require('./config/generateId');
const urlencodeParse = bodyParser.urlencoded({ extended: false });

//路由部分
const signIn = require('./api/signIn');
const uploadImg = require('./api/uploadImg');
const verify = require('./api/verify');
const mine = require('./api/mine');
const video = require('./api/video');

app.all('*', function(req, res, next) {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Credentials', true);
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    res.header('Access-Control-Allow-Methods', '*');
    // res.header('Content-Type', 'application/json;charset=utf-8');
    next();
})

//静态资源
app.use(express.static(__dirname + '/static'));
// 正常接口部分
app.use('*', jsonParser);
app.use('/', verify);
app.use('/mine', mine);
app.use('/signIn', signIn);
app.use('/uploadImg', uploadImg);
app.use('/video', video);

app.listen(8000, () => console.log('libilibi server is running on the port 8000!'));